package com.cwz.gateway.config;

import com.cwz.core.text.CharsetKit;
import com.cwz.gateway.handler.ValidateCodeHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;

/**
 * @program: w-demo
 * @description: 路由配置信息
 * @author: Wen
 **/
@Configuration
public class RouterFunctionConfig {
	@Autowired
	private ValidateCodeHandler validateCodeHandler;

	@Bean
	public RouterFunction routerFunction() {
		return RouterFunctions.route(
			RequestPredicates.GET("/code")
				.and(RequestPredicates.accept(new MediaType("application", "json", CharsetKit.CHARSET_UTF_8))),
			validateCodeHandler
		);
	}
}
